package com.taptech.doufu.ui.view;

import com.taptech.doufu.R;
import com.taptech.doufu.listener.HttpResponseListener;
import com.taptech.doufu.services.NovelCreateServices;
import com.taptech.doufu.net.httputils.HttpResponseObject;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.ImageView;

public class NovelModifiedStatusDialog extends Dialog implements HttpResponseListener,android.view.View.OnClickListener{
	private ImageView serialStatus,completeStatus;
	private boolean isComplete;
	private String novelId;
	private Handler mHandler;
	public NovelModifiedStatusDialog(Context context,int theme,boolean isComplete,String novelId,Handler mHandler) {
		super(context,theme);
		// TODO Auto-generated constructor stub
		this.isComplete=isComplete;
		this.novelId=novelId;
		this.mHandler=mHandler;
	}
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_novel_modified_status);
		completeStatus=(ImageView)findViewById(R.id.dialog_novel_modified_complete_status);
		serialStatus=(ImageView)findViewById(R.id.dialog_novel_modified_serial_status);
		findViewById(R.id.dialog_novel_modified_complete_layout).setOnClickListener(this);
		findViewById(R.id.dialog_novel_modified_serial_status_layout).setOnClickListener(this);
		setComplete();
	}
	private void setComplete(){
		if (isComplete) {
			completeStatus.setImageResource(R.drawable.novel_create_radio_select);
			serialStatus.setImageResource(R.drawable.novel_create_radio_default);
		}else{
			serialStatus.setImageResource(R.drawable.novel_create_radio_select);
			completeStatus.setImageResource(R.drawable.novel_create_radio_default);
		}
	}
	@Override
	public void handleResponse(int handleType, HttpResponseObject response) {
		// TODO Auto-generated method stub

	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		dismiss();
		int finished=0;
		if (v.getId()==R.id.dialog_novel_modified_complete_layout) {
			finished=1;
		}else{
			finished=0;
		}
		if (mHandler!=null) {
			mHandler.sendEmptyMessage(finished);
		}
		NovelCreateServices.getInstance().saveTopicNovel(NovelModifiedStatusDialog.this, novelId, null, null, null, null, finished+"",false);
	}
}
